# 精简版live555库Makefile

# 交叉编译工具链设置
CROSS_COMPILE ?= /home/hxg/Desktop/My_Demo/Tassadar-T32-1.0.6-20250613/software/pc/toolchain/mips-gcc540-glibc222-r3.3.7.mxu2.cve/bin/mips-linux-uclibc-gnu-

# 编译选项
INCLUDES = -I$(CURDIR)/include -I$(CURDIR)/include/BasicUsageEnvironment -I$(CURDIR)/include/UsageEnvironment -I$(CURDIR)/include/groupsock -I$(CURDIR)/include/liveMedia
COMPILE_OPTS = $(INCLUDES) -I. -O2 -fPIC -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOCALE_NOT_USED -std=c++11

# 编译器设置
C_COMPILER = $(CROSS_COMPILE)gcc
C_FLAGS = $(COMPILE_OPTS)
CPLUSPLUS_COMPILER = $(CROSS_COMPILE)g++
CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -DBSD=1

# 文件类型
OBJ = o
LIB_SUFFIX = a

# 库文件
LIBRARY_LINK = $(CROSS_COMPILE)ar cr

# 子目录编译规则
SUBDIRS = UsageEnvironment BasicUsageEnvironment groupsock liveMedia

all: $(SUBDIRS)

# 编译子目录
$(SUBDIRS):
	$(MAKE) -C src/$@ CROSS_COMPILE="$(CROSS_COMPILE)" INCLUDES="$(INCLUDES) -I../../include -I../../include/$@" COMPILE_OPTS="$(COMPILE_OPTS)" C_COMPILER="$(C_COMPILER)" C_FLAGS="$(C_FLAGS)" CPLUSPLUS_COMPILER="$(CPLUSPLUS_COMPILER)" CPLUSPLUS_FLAGS="$(CPLUSPLUS_FLAGS)" OBJ="$(OBJ)" LIBRARY_LINK="$(LIBRARY_LINK)" LIB_SUFFIX="$(LIB_SUFFIX)"

# 编译应用程序
apps:
	@echo "Building applications..."
	$(MAKE) -C apps CXX=$(CPLUSPLUS_COMPILER) CXXFLAGS="$(CPLUSPLUS_FLAGS)" INCLUDES="$(INCLUDES)"

# 清理
clean:
	for dir in $(SUBDIRS); do \
		$(MAKE) -C src/$$dir clean; \
	done

# 安装头文件
install_headers:
	@echo "Headers are already in place in the include directory"